package com.mt.controller;

import com.mt.constants.Result;
import com.mt.pojo.AdminUser;
import com.mt.service.AdminService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Wang
 * @Description 管理员控制
 * @date 2021/2/25-17:34
 */

@Slf4j
@RestController
public class AdminController {
    @Autowired
    AdminService adminService;
    @GetMapping("/admin")
    public Result getAdminInfo(@RequestParam("adminId") String adminId){
        Result<Object> result = new Result<>();
        result.success(adminService.getAdminCinemaId(adminId));
        return result;
    }

    @PostMapping("/admin/distribute")
    public Result distributeAdmin2Cinema(@RequestBody AdminUser admin){
        Result<Object> result = new Result<>();
        result.success(adminService.addAdminUser(admin));
        return result;
    }

    @PostMapping("/admin/login")
    public Result adminLogin(@RequestBody AdminUser admin){
        log.info(admin.getUserId());
        log.info(admin.getPassword());
        Result<Object> result = new Result<>();
        result.success(adminService.adminLogin(admin));
        return result;
    }


}
